package com.xiaobai.spike.web.auth;

import com.xiaobai.spike.entity.User;
import com.xiaobai.spike.model.response.TokenResponse;
import com.xiaobai.spike.sdk.lang.ApiResponse;
import com.xiaobai.spike.service.auth.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @PostMapping("/add")
    public ApiResponse<Integer> userAdd(@RequestBody User user) {
        return ApiResponse.success(userService.add(user));
    }

    @PostMapping("/login")
    public ApiResponse<TokenResponse> login(@RequestBody User user) {
        return ApiResponse.success(userService.login(user));
    }
}
